
#ifndef _FEATURE_TENSOR_H_
#define _FEATURE_TENSOR_H_

#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "onnxruntime_cxx_api.h"

#include "model.h"
#include "dataType.h"
typedef unsigned char uint8;

class FeatureTensor
{
public:
	static FeatureTensor* getInstance();
	bool init(const std::string &model_path);
	bool getRectsFeature(const cv::Mat& img, DETECTIONS& d);

private:
	struct preprocess_info {
        cv::Mat resized_image;
        size_t tpixels;
        std::array<int64_t, 4> input_shape_info;
        float x_factor;
        float y_factor;
    };
	FeatureTensor();
	// 禁止拷贝和赋值
	FeatureTensor(const FeatureTensor&) = delete;
	FeatureTensor& operator = (const FeatureTensor&) = delete;
	// FeatureTensor(const FeatureTensor&);
	// FeatureTensor& operator = (const FeatureTensor&);
	static FeatureTensor* instance;
	
	~FeatureTensor();

	void tobuffer(const std::vector<cv::Mat> &imgs, uint8 *buf);

	preprocess_info preprocess(const cv::Mat& image);

	int feature_dim=1000;
	// tensorflow::Session* session;
	// std::vector<tensorflow::Tensor> output_tensors;
	// std::vector<tensorflow::string> outnames;
	// tensorflow::string input_layer;
	Ort::SessionOptions session_options;
	std::unique_ptr<Ort::Session> session= nullptr;
	std::vector<std::string> input_node_name;
	std::vector<std::string> output_node_name;
	int input_model_height=224;
    int input_model_width=224;
    int output_model_height=84;
    int output_model_width=8400;   
	
public:
	void test();
};
#endif // _FEATURE_TENSOR_H_